<ol class="breadcrumb" >
    <li> <i class="fa fa-anchor"></i>
        &nbsp;短信管理
    </li>
    <li>短信发送</li>
</ol>
<h2>
    &nbsp;&nbsp;
    <span class="">&nbsp;&nbsp;
        <i class="glyphicon glyphicon-pushpin"></i>&nbsp;
        发送短信
    </span>
</h2>
<form  method="post" action="" id="form_check" name="form1">
    <table class="table table-bordered table-striped" bordercolor="#C0C0C0">
        <tbody>
            <tr>
                <td align="right">手机：</td>
                <td colspan="4">
                    <input  name="mobile" maxlength='11' class="form-control required" style="width: 540px" type="text">
                </td>
            </tr>
            <tr>
                <td align="right" valign="middle" >内容：</td>
                <td colspan="6">
                    <span>
                        <textarea id="informContent" maxlength='140' rows="5" class="form-control required" name="informContent" style="width: 100%"></textarea>
                    </span>
                    <span></span>
                </td>
            </tr>
        </tbody>
    </table>
    <p align="center" id="message" style="color:red;"></p>
    <p align="center">
        <button id="addBtn" class="btn btn-mcit"  style="width: 80px">发送</button>
    </p>
</form>
<import file="js.maskedinput" />
<script>
    $(document).ready(function () {
        $("#addBtn").click(function(){
            //手机号码正则验证
           var mobile = $('input[name="mobile"]').val();
           if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(mobile))){
               $("#message").html("不是完整的11位手机号或者正确的手机号前七位");
           }else{
               $("#message").html("");
           }
           var informContent = $("#informContent").val();
           if(informContent.length > 140){
               $("#message").html("短信内容不能超过140字");
           }else{
               $("#message").html("");
           }
            var formParam = $("#form_check").serialize();
            $.ajax({
                type:'post',
                url:'__URL__/???',
                data:formParam,
                cache:false,
                dataType:'json',
                success:function(data){
                    alert(data);
                }
            });
        });
        jQuery.extend(jQuery.validator.messages, {
            required: "必选字段"
        });

        $("#form_check").validate(
                {
                    //debug: true,
                    //调试模式取消submit的默认提交功能
                    onkeyup: false,
                    errorClass: "mcit-error",
                    validClass: "mcit-valid",
                    email:true,
                    // submitHandler: function(form){
                    //     //alert("提交服务器");
                    //     form.submit();提交表单
                    // },
                    rules: {
                        num: {
                            minlength: 9,
                        }
                    },
                    messages: {
                        num: {
                            minlength: "格式不对",
                        }
                    },
                    errorPlacement: function (error, element) {
                        error.appendTo(element.next());
                    },
                    highlight: function (element, errorClass) {
                        //$(element).addClass(errorClass);
                        $(element).parent().addClass(errorClass);
                        $(element).next().css("display", "block");
                        $(element).next().next().hide();
                    },
                    success: function (label) {
                        label.parent().next().hide();
                        label.addClass('mcit-valid');
                        label.parent().parent().addClass('mcit-valid');
                        label.parent().css("display", "block");
                        label.html('<i class="fa fa-check"></i>&nbsp;OK');
                    }
                }
        );
    })
</script>